Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

394
Views
requireValueInRange error - The parameters (number[]) don't match the method signature

I have a google app script which (amongst other things) provides a series of drop downs in cells based on the values chosen in the previous cell. Essentially, when a cell value is selected, that value is used in a Google Big Query lookup, and the next cell is populated with values from Big Query.

I enforce the validation of the options available in the dropdown via the function below

function applyValidationToCell(list, cell) {
 
 //create a valdation rule, essentially that the available values must be in the list passed ot the function
 var rule = SpreadsheetApp.newDataValidation()
   //.requireValueInList(list)
   .requireValueInRange(list)
   .setAllowInvalid(false)
   .build();
 
 cell.setDataValidation(rule);
}

This all worked well until I came across a case where there are over 500 options in the select list and I hit the error The data validation rule has more items than the limit of 500. Use the ‘List from a range’ criteria instead.

I’ve looked at the docs at https://developers.google.com/apps-script/reference/spreadsheet/data-validation-builder#requireValueInRange(Range) and also read this SO questions Need answer to “The parameters (number[]) don't match the method signature for SpreadsheetApp.Range.setValues” error and then @TheMaster's helpful answers at How do you resolve a "The parameters (number[]) don't match the method signature for SpreadsheetApp.Range.setValues" error and What does the range method getValues() return and setValues() accept?

When I was using .requireValueInList(list) the shape of the data passed to the function was ["Donruss","Leaf","Panini","Topps"]

To deal with requireValueInRange I’ve tried modifying the structure to 2D arrays as suggested in the answers above e.g. [["Donruss"],["Leaf"],["Panini"],["Topps"]] and [["Donruss","Leaf","Panini","Topps"]]

However, I always get the error Exception: The parameters (number[]) don't match the method signature for SpreadsheetApp.DataValidationBuilder.requireValueInRange.

Can anyone please advise on the correct way to pass values to requireValueInRange?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Description

Here is a simple example of how to use a range for a data validation rule.

In your case save the Big Query results to a sheet using setValues() then flush() then add the data validation rule for the cell your interested in.

Script

function runTest() {
  try {
    let spread = SpreadsheetApp.getActiveSpreadsheet();
    let sheet = spread.getSheetByName("Sheet1");
    let cell = sheet.getRange("A6");
    let range = sheet.getRange("A1:A4");
    let rule = SpreadsheetApp.newDataValidation().requireValueInRange(range).build();
    cell.setDataValidation(rule);
  }
  catch(err) {
    console.log(err);
  }
}

Reference

  • https://developers.google.com/apps-script/reference/spreadsheet/data-validation-builder
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!